package com.ruoyi.web.controller.house;

import java.util.List;
import javax.servlet.http.HttpServletResponse;

import com.ruoyi.fees.domain.HouseFeesT;
import com.ruoyi.fees.service.IHouseFeesTService;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 收费标准Controller
 * 
 * @author ruoyi
 * @date 2024-01-09
 */
@RestController
@RequestMapping("/house/fees")
public class HouseFeesTController extends BaseController
{
    @Autowired
    private IHouseFeesTService houseFeesTService;

    /**
     * 查询收费标准列表
     */
    @GetMapping("/list")
    public TableDataInfo list(HouseFeesT houseFeesT)
    {
        startPage();
        List<HouseFeesT> list = houseFeesTService.selectHouseFeesTList(houseFeesT);
        return getDataTable(list);
    }

    /**
     * 导出收费标准列表
     */
    @Log(title = "收费标准", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, HouseFeesT houseFeesT)
    {
        List<HouseFeesT> list = houseFeesTService.selectHouseFeesTList(houseFeesT);
        ExcelUtil<HouseFeesT> util = new ExcelUtil<HouseFeesT>(HouseFeesT.class);
        util.exportExcel(response, list, "收费标准数据");
    }

    /**
     * 获取收费标准详细信息
     */
    @GetMapping(value = "/{feesId}")
    public AjaxResult getInfo(@PathVariable("feesId") Long feesId)
    {
        return AjaxResult.success(houseFeesTService.selectHouseFeesTByFeesId(feesId));
    }

    /**
     * 新增收费标准
     */
    @Log(title = "收费标准", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody HouseFeesT houseFeesT)
    {
        houseFeesT.setCreater(getUsername());
        return toAjax(houseFeesTService.insertHouseFeesT(houseFeesT));
    }

    /**
     * 修改收费标准
     */
    @Log(title = "收费标准", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody HouseFeesT houseFeesT)
    {
        return toAjax(houseFeesTService.updateHouseFeesT(houseFeesT));
    }

    /**
     * 删除收费标准
     */
    @Log(title = "收费标准", businessType = BusinessType.DELETE)
	@DeleteMapping("/{feesIds}")
    public AjaxResult remove(@PathVariable Long[] feesIds)
    {
        return toAjax(houseFeesTService.deleteHouseFeesTByFeesIds(feesIds));
    }
}
